package com.example.ossservice.controller;

import com.example.commonutils.R;
import com.example.ossservice.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/oss")
public class FileController {
    @Autowired
    private FileService fileService;
    @PostMapping("/uploadFile")
    public R uploadFile(MultipartFile file){
        String url = fileService.uploadFile(file);
        return R.ok().data("url",url);
    }
    @DeleteMapping("/deleteFile/{fileName}")
    public R deleteFile(@PathVariable String fileName){
        fileService.delete(fileName);
        return R.ok();
    }
}
